package pingce.share.model;

import java.io.Serializable;
import java.util.LinkedList;

import pingce.share.model.raw.Sentence;
import pingce.share.model.raw.Weibo;
import pingce.share.util.*;

/**
 * 存放每条微博的处理结果。
 * @author ucai
 *
 */
public class WeiboResult implements Serializable {
	private static final long serialVersionUID = 3960803556657262771L;
	private LinkedList<SentenceResult> sentenceResultList;
	private Weibo w;
	
	public WeiboResult(Weibo w, SentenceProcessor sp){
		this.sentenceResultList = new LinkedList<SentenceResult>();
		this.w = w;
		WrappedSplitter ws = new WrappedSplitter(sp.splitter);
		for(Sentence s : w.sentences){
			SentenceResult sr = new SentenceResult(w.id, s, sp, ws);
			this.sentenceResultList.add(sr);
		}
	}

	public Weibo getW() {
		return w;
	}

	public void setW(Weibo w) {
		this.w = w;
	}

	public LinkedList<SentenceResult> getSentences() {
		return sentenceResultList;
	}

	public void setSentences(LinkedList<SentenceResult> sentences) {
		this.sentenceResultList = sentences;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		StringBuilder sb = new StringBuilder();
		sb.append("weibo result(weibo id = " + w.id + "):\n");
		for(SentenceResult sr : this.sentenceResultList)
			sb.append(sr.toString() + "\n");
		
		return sb.toString();
	}
}
